package com.xbongbong.paas.log.model.impl;

import com.xbongbong.paas.log.entity.OutLinkQueryLogEntity;
import com.xbongbong.paas.log.model.OutLinkQueryLogModel;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("OutLinkQueryModel")
public class OutLinkQueryLogModelImpl implements OutLinkQueryLogModel{

    private static final Logger LOG = LoggerFactory.getLogger(OutLinkQueryLogModelImpl.class);

    @Resource
    private MongoTemplate mongoTemplate;

    /**
     * 保存外联查询日志
     * @param entity 登录日志实体
     */
    @Override
    @Async(value = "sysLogThreadPool")
    public Integer insert(OutLinkQueryLogEntity entity) throws XbbException {
        try {
            mongoTemplate.save(entity);
        } catch (Exception e) {
            LOG.error("OutLinkQueryLogModelImpl.insert 执行出错", e);
            throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001);
        }

        return 1;
    }

    @Override
    public Integer update(OutLinkQueryLogEntity entity) throws XbbException {
        return null;
    }

    @Override
    public List findEntitys(Map<String, Object> param) {
        return null;
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return null;
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }
}
